/*
package com.eliza.v.http.verify

import io.vertx.core.AbstractVerticle
import io.vertx.core.json.JsonObject
import io.vertx.ext.web.Router
import io.vertx.ext.web.RoutingContext
import io.vertx.ext.web.handler.BodyHandler
import io.vertx.json.schema.SchemaParser
import io.vertx.json.schema.SchemaRouter
import io.vertx.json.schema.SchemaRouterOptions
import io.vertx.json.schema.draft7.dsl.Schemas.*

*/
/**
 * @author [Francesco Guardiani](https://slinkydeveloper.com)
 *//*

class ValidationExampleServer : AbstractVerticle() {
    @Throws(Exception::class)
    override fun start() {
        // The schema parser is required to create new schemas
        val parser: SchemaParser = SchemaParser.createDraft7SchemaParser(
            SchemaRouter.create(vertx, SchemaRouterOptions())
        )
        val router = Router.router(vertx)

        // If you want to validate bodies, don't miss that handler!
        router.route().handler(BodyHandler.create())

        // Create Validation Handler with some stuff
        val validationHandler: ValidationHandler = ValidationHandler.builder(parser)
            .queryParameter(param("parameterName", intSchema()))
            .pathParameter(param("pathParam", numberSchema()))
            .body(
                formUrlEncoded(
                    objectSchema()
                        .property("r", intSchema())
                        .property("g", intSchema())
                        .property("b", intSchema())
                )
            )
            .build()
        router.post("/hello/:pathParam") // Mount validation handler
            .handler(validationHandler) //Mount your handler
            .handler { routingContext: RoutingContext ->
                // To consume parameters you can get it in the "classic way" of Vert.x Web
                // or you can use the RequestParameters that contains parameters already parsed (and maybe transformed)
                // Get RequestParameters container
                val params: RequestParameters = routingContext.get(ValidationHandler.REQUEST_CONTEXT_KEY)

                // Get parameters
                val parameterName: Int = params.queryParameter("parameterName").getInteger()
                val pathParam: Float = params.pathParameter("pathParam").getFloat()

                // Get body
                val rgbObject: JsonObject = params.body().getJsonObject()
            }

        // A very basic example of JSON body validation
        router.post("/jsonUploader")
            .handler(
                ValidationHandler.builder(parser)
                    .body(
                        json(
                            objectSchema()
                                .additionalProperties(stringSchema())
                        )
                    )
                    .build()
            )
            .handler { routingContext: RoutingContext ->
                val params: RequestParameters = routingContext.get("parsedParameters")
                val body: JsonObject = params.body().getJsonObject()
            }

        // Custom handler for the ValidationException
        router.errorHandler(400) { routingContext: RoutingContext ->
            val failure = routingContext.failure()
            if (failure is BadRequestException) {
                // Something went wrong during validation!
                val validationErrorMessage = failure.message
                routingContext.response().setStatusCode(400).end()
            }
        }
        vertx.createHttpServer().requestHandler(router).listen()
    }

    companion object {
        // Convenience method so you can run it in your IDE
        @JvmStatic
        fun main(args: Array<String>) {
            Runner.runExample(ValidationExampleServer::class.java)
        }
    }
}*/
